package com.example.mygame;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class ShopActivity extends AppCompatActivity {

    private Button button1;
    private Button button2;
    private Button button3;
    private  Weapon weapon;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);

        button1=findViewById(R.id.button1);
        button2=findViewById(R.id.button2);
        button3=findViewById(R.id.button3);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                weapon=new Weapon("Sword",300,50,100);
                setWeaponResult();
            }
        });

        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                weapon=new Weapon("Shield",50,300,100);
                setWeaponResult();
            }
        });

        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                weapon=new Weapon("SwordandShield",300,300,50);
                setWeaponResult();
            }
        });

    }

    private  void setWeaponResult(){
        Intent data=new Intent();
        data.putExtra("weapon",weapon);
        setResult(RESULT_OK,data);
        finish();
    }

}
